package com.wlh.animation.demo;

import com.wlh.animation.R;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by weilh on 2018/3/5.
 */

public class SlideAnimAct2 extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slide_anim2);
        setTitle("NestedScrollView");
        NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.scroll);
        scrollView.setNestedScrollingEnabled(true);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
        setAdapter(recyclerView, 100);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }

    private void setAdapter(RecyclerView view, final int num) {
        view.setAdapter(new RecyclerView.Adapter() {
            @Override
            public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                TextView textView = new TextView(SlideAnimAct2.this);
                RecyclerView.ViewHolder holder = new RecyclerView.ViewHolder(textView) {};
                return holder;
            }

            @Override
            public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
                ((TextView)holder.itemView).setText("" + position);
            }

            @Override
            public int getItemCount() {
                return num;

            }
        });
    }
}
